package com.matt.foundation.DO.course;

import com.matt.domain.course.CoursePlanClasses;
import com.matt.domain.course.CourseTemplateAreaBuild;
import com.matt.domain.course.PrepareCourse;
import lombok.Data;

import java.util.Map;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/11/27
 * *******************************
 */
@Data
public class PadCourseTemplate3Vo {
    private String courseName;
    private String typeName;
    private String content;
    private Integer beginMonth;
    private Integer endMonth;
    private String attachments;

    public static PadCourseTemplate3Vo ofCourse(CoursePlanClasses coursePlanClasses, CourseTemplateAreaBuild template){
        PadCourseTemplate3Vo vo = new PadCourseTemplate3Vo();
        vo.setCourseName(coursePlanClasses.getCourseName());
        vo.setTypeName(coursePlanClasses.getTypeName());
        vo.setContent(template.getContent());
        vo.setBeginMonth(template.getBeginMonth());
        vo.setEndMonth(template.getEndMonth());
        vo.setAttachments(template.getAttachments());
        return vo;
    }

    public static PadCourseTemplate3Vo ofPrepareCourse(PrepareCourse prepareCourse, Map prepareData){

        PadCourseTemplate3Vo vo = new PadCourseTemplate3Vo();
        vo.setCourseName(prepareCourse.getCourseName());
        vo.setTypeName(prepareCourse.getTypeName());

        vo.setContent((String) prepareData.get("content"));
        vo.setBeginMonth(Integer.parseInt((String)prepareData.get("beginMonth")));
        vo.setEndMonth(Integer.parseInt((String)prepareData.get("endMonth")));
        vo.setAttachments((String)prepareData.get("attachments"));

        return vo;
    }
}
